package com.itheima.多态的使用;

public abstract class Animal {
    public abstract void eat();
}

class Cat extends Animal {

    @Override
    public void eat() {
        System.out.println("给猫吃鱼");
    }
}

class Dog extends Animal {

    @Override
    public void eat() {
        System.out.println("给狗吃骨头");

    }
}

class Pig extends Animal {

    @Override
    public void eat() {
        System.out.println("给猪吃白菜");
    }
}

//饲养员类
class CiYangYuan {
    public void userCat(Animal an) {
        an.eat();
    }
}

class T3 {
    public static void main(String[] args) {
        //创建饲养员对象
        CiYangYuan cyy=new CiYangYuan();
        //创建猫,狗,猪的对象
        Cat cat=new Cat();
        Dog dog=new Dog();
        Pig pig=new Pig();
        cyy.userCat(cat);
        cyy.userCat(dog);
        cyy.userCat(pig);
    }
}